﻿using Glue.Converters;
using Xunit;

namespace GlueTests.BaseConverterTests
{
    public class When_mapping_between_nulls
    {
        private readonly IConverter converter;
        private readonly TestConverterBetweenStringAndInt testObject;

        public When_mapping_between_nulls()
        {
            testObject = new TestConverterBetweenStringAndInt();
            converter = testObject;
        }

        [Fact]
        public void Should_return_null_when_both_objects_are_null()
        {
            Assert.Null(converter.Map(null, null));
        }

        [Fact]
        public void Should_return_value_when_nullable_type_is_null()
        {
            var decimalConverter = new QuickConverter<decimal, decimal?>
               (t1 => t1 == 0M ? null : (decimal?)(t1), t2 => t2.HasValue ? t2.Value : 0M);
            Assert.Equal(0, decimalConverter.MapTowardsLeft(null)); 
        }

    }
}
